<?php
/**
 * sdPHP
 * @author     码农<8044023@qq.com>
 * @copyright  sdPHP
 * @license    https://gitee.com/cq8044023/sdphp
 */
namespace sdphp\lib\Route;
use sdphp\lib\Route\IRoute;
use sdphp\lib\CoreBase\PortManagr;
use sdphp\lib\Config;
use sdphp\lib\Exception;
class NormalRoute implements IRoute{
    private $client_data;
    public $is_status=true;
    public function __construct(){ $this->client_data=new \stdClass();}
    public function handleClientRequest($data,$prot){
        foreach (array_values(Config::getConfig()["DataFormat"]) as $v){
            $val=$data[$v];
            if (!empty($val)){
                $this->client_data->$v=$val;
            }
            (!in_array($v, array_keys($data))) && $this->is_status=false;
        }
        if ($prot!=PortManagr::SOCK_TCP && PortManagr::SOCK_WS!=$prot){
            $this->is_status=false;
        }
        return $this;
    }
    public function getModel(){
        return $this->client_data->model;
    }
    
    public function getController(){ 
        return $this->client_data->controller;
    }
    
    public function getMethod(){
        return $this->client_data->method;
    }
}